package zzyl;

import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.core.auth.Auth;
import com.baidubce.qianfan.model.chat.ChatResponse;

public class Demo {
    public static void main(String[] args) {
        // 使用安全认证AK/SK鉴权，替换下列示例中参数，安全认证Access Key替换your_iam_ak，Secret Key替换your_iam_sk，如何获取请查看https://cloud.baidu.com/doc/Reference/s/9jwvz2egb
        Qianfan qianfan = new Qianfan(Auth.TYPE_OAUTH,"j2FFBF5L8DZEf6fGqR14shAv", "GFzKORqfTXQMlII6kEVUXIvxd4oH2l0W");
        
        // 指定模型
       ChatResponse resp = qianfan.chatCompletion()
                .model("ERNIE-4.0-8K-Preview")
                .addMessage("user", "你好")
                .temperature(0.7)// 自定义超参数，默认值是0.8，数值越大，结果越随机
                .maxOutputTokens(2048)// 设置最大输出token数
                .responseFormat( "json_object")// 设置输出格式为json
                .execute();
        System.out.println(resp.getResult());
    }
}